package com.matt.docpro.service;

import com.matt.docpro.mapper.BlogMapper;
import com.matt.docpro.mapper.MessageMapper;
import com.matt.docpro.model.Blog;
import com.matt.docpro.model.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * AppointmentService
 * Created by on 2024/02/20.
 */
@Service
public class MessageService {

    @Autowired
    MessageMapper messageMapper;

    public List<Message> getChatMessage(String user1, String user2) {
        return messageMapper.getChatMessage(user1, user2);
    }

    public Message getLatestMessage(String user1, String user2) {
        return messageMapper.getLatestMessage(user1, user2);
    }

    public void insert(Message message) {
        messageMapper.insert(message);
    }

    public int getUnreadCount(String senderId, String receiverId) {
        return messageMapper.getUnreadCount(senderId, receiverId);
    }

    public void updateRead(String senderId, String receiverId){
        messageMapper.updateRead(senderId, receiverId);
    }

}
